package com.bluesky.comm.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bluesky.utils.CollUtils;
import org.apache.poi.ss.formula.functions.T;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

public interface IBaseService extends IService<T> {

    @Override
    default List<T> listByIds(Collection<? extends Serializable> idList){
        if (CollUtils.isEmpty(idList)){
            return CollUtils.emptyArrayList();
        }
        return IService.super.listByIds(idList);
    }

    default T findOne(Wrapper<T> queryWrapper){
        Page<T> page = this.page(new Page<>(1,1,false),queryWrapper);
        return CollUtils.getFirst(page.getRecords());
    }
}
